package com.xmg.p2p.base.controller;

import com.xmg.p2p.base.domain.Userinfo;
import com.xmg.p2p.base.service.ISystemDictionaryService;
import com.xmg.p2p.base.service.IUserinfoService;
import com.xmg.p2p.base.util.JSONResult;
import com.xmg.p2p.base.util.RequireLogin;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by  zsl on  Date: 2017-11-04
 */
@Controller
public class BasicInfoController {

    @Autowired
    private IUserinfoService userinfoService;

    @Autowired
    private ISystemDictionaryService systemDictionaryService;

@RequireLogin
    @RequestMapping("basicInfo")
    public String basicInfo(Model model){
    model.addAttribute("userinfo",userinfoService.getCurrent());
    model.addAttribute("educationBackgrounds",this.systemDictionaryService.listByParentSn("educationBackground"));
    model.addAttribute("incomeGrades",this.systemDictionaryService.listByParentSn("incomeGrade"));
    model.addAttribute("marriages",this.systemDictionaryService.listByParentSn("marriage"));
    model.addAttribute("kidCounts",this.systemDictionaryService.listByParentSn("kidCount"));
    model.addAttribute("houseConditions",this.systemDictionaryService.listByParentSn("houseCondition"));
    return "userInfo";

    }

    @RequireLogin
    @RequestMapping("basicInfo_save")
    public JSONResult basicInfoSave(Userinfo userinfo){
    this.userinfoService.updateBasicInfo(userinfo);
    return new JSONResult();
    }



}
